<?php
    class htmlHelper{

        /**
         * Create <a> link
         */
        public function link($title,$url='',$param=array())
        {
            return $this->url($title, CustomController::get()->url($url), $param);
        }

        public function url($title,$url='',$param=array())
        {
            return Html::el('a',$param)->href($url)->title($title)->setText($title);
        }

        public function imgUrl($url, $img, $alt = '')
        {
            if('http://' != substr($img,0,7) )
                $img = Application::get()->Http->getUri(true).$img;

            if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$url))
                $url = CustomController::get()->url($url);

            $a = Html::el('a')->href($url);
            $a->create('img')->src($img)->alt($alt);
            return $a;
        }

        public function css($src,$link=true){
            return Html::el('link')->rel('stylesheet')->type('text/css')->href($link?Application::get()->Http->getUri(true).$src:$src);
        }

        public function script($src,$type='text/javascript',$link=true){
            return Html::el('script')->type($type)->src($link?Application::get()->Http->getUri(true).$src:$src);
        }

        public function icon($src,$link=true){
            return Html::el('link')->rel('shortcut icon')->href($link?Application::get()->Http->getUri(true).$src:$src);
        }

        public function img($src,$alt='',$link=true){
            return Html::el('img')->alt($alt)->src($link?Application::get()->Http->getUri(true).$src:$src);
        }
    }
?>